
package dao;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Jeisse
 */
public class ConnectionFactory {
    
    public static Connection getConnection()
    {       
        
        // Strings de conexão
        String url = "jdbc:mysql://localhost:3306/cgd";//"";
        String login = "root";//"";
        String senha = "";//"";
        String driver = "com.mysql.jdbc.Driver";//"";
        try {
            //Passo 1
            Class.forName(driver);
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
        System.out.println("Conectando ao banco");
        try {
            //Passo 2
            return DriverManager.getConnection(url, login, senha);
        } catch(SQLException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }        
    
    
}
